#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
int n,C,a[N];
signed main() {
	freopen("minimize.in","r",stdin);
	freopen("minimize.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>C;
	for(int i=1;i<=n;i++) cin>>a[i];
	if(C==0) {
		cout<<"0";
		return 0;
	}
	int ans=1e18;
	int sum=0;
	for(int i=0;i<=n;i++) {
		sum+=a[i];
		ans=min(ans,C*(n-i)+a[i]*i-sum);
	}
	cout<<ans;
	return 0;
}

